home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
JFC.bin
/
JToolTip.java
< prev
next >
Wrap
Text File
|
1998-06-30
|
6KB
|
186 lines
/*
* %W% %E%
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing;
import com.sun.java.swing.plaf.*;
import com.sun.java.accessibility.*;
/**
* Used to display a "Tip" for a Component. Typically components provide api
* to automate the process of using ToolTips. For example, any Swing component
* can use the JComponent <code>setToolTipText</code> method to specify the text
* for a standard tooltip. A component that wants to create a custom ToolTip
* display can override JComponent's <code>createToolTip</code> method and use
* a subclass of this class.
* <p>
* For the keyboard keys used by this component in the standard Look and
* Feel (L&F) renditions, see the
* <a href="doc-files/Key-Index.html#JToolTip">JToolTip</a> key assignments.
* <p>
* See <a href="http://java.sun.com/docs/books/tutorial/ui/swing/tooltip.html">How to Use Tool Tips</a>
* in <a href="http://java.sun.com/Series/Tutorial/index.html"><em>The Java Tutorial</em></a>
* for further documentation.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*
* @see JComponent#setToolTipText
* @see JComponent#createToolTip
* @version %I% %G%
* @author Dave Moore
* @author Rich Shiavi
*/
public class JToolTip extends JComponent implements Accessible {
String tipText;
JComponent component;
/** Creates a tool tip. */
public JToolTip() {
updateUI();
}
/**
* Returns the L&F object that renders this component.
*
* @return the ToolTipUI object that renders this component
*/
public ToolTipUI getUI() {
return (ToolTipUI)ui;
}
/**
* Notification from the UIFactory that the L&F has changed.
* Called to replace the UI with the latest version from the
* UIFactory.
*
* @see JComponent#updateUI
*/
public void updateUI() {
setUI((ToolTipUI)UIManager.getUI(this));
}
/**
* Returns the name of the L&F class that renders this component.
*
* @return "ToolTipUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
public String getUIClassID() {
return "ToolTipUI";
}
/**
* Sets the text to show when the tool tip is displayed.
*
* @param tipText the String to display
*/
public void setTipText(String tipText) {
this.tipText = tipText;
}
/**
* Returns the text that is shown when the tool tip is displayed.
*
* @return the String that is displayed
*/
public String getTipText() {
return tipText;
}
/**
* Specifies the component that the tooltip describes.
*
* @see JComponent#createToolTip
*/
public void setComponent(JComponent c) {
component = c;
}
/**
* @return the component that the tooltip describes.
*
* @see JComponent#createToolTip
*/
public JComponent getComponent() {
return component;
}
/////////////////
// Accessibility support
////////////////
/**
* Get the AccessibleContext associated with this JComponent
*
* @return the AccessibleContext of this JComponent
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJToolTip();
}
return accessibleContext;
}
/**
* The class used to obtain the accessible role for this object.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*/
protected class AccessibleJToolTip extends AccessibleJComponent {
/**
* Get the accessible description of this object.
*
* @return a localized String describing this object.
*/
public String getAccessibleDescription() {
if (accessibleDescription != null) {
return accessibleDescription;
} else {
return getTipText();
}
}
/**
* Get the role of this object.
*
* @return an instance of AccessibleRole describing the role of the
* object
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TOOL_TIP;
}
}
}